package com.sxz.sbs.module.client.presenter;

import com.sxz.sbs.app.App;
import com.sxz.sbs.module.client.bean.StallRequireBean;
import com.sxz.sbs.module.client.view.AddClientView;
import com.sxz.sbs.rx.RxPresenter;
import com.sxz.sbs.rx.RxSubscriber;
import com.sxz.sbs.rx.RxUtil;

import java.util.HashMap;
import java.util.List;

/**
 * 新增业主
 */
public class AddClientPresenter extends RxPresenter<AddClientView>{
    /**
     * @param map
     */
    public void getAddClient (final HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().getAddClient(map)
                .compose(RxUtil.<String>handleResult())
                .subscribeWith(new RxSubscriber<String>(mView,true){
                    @Override
                    public void onNext(String data) {
                        mView.onAddClientSuccess(data);
                    }
                })
        );
    }
    /**
     * @param map
     */
    public void getIntentLabel (final HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().getIntentLabel(map)
                .compose(RxUtil.<List<StallRequireBean>>handleResult())
                .subscribeWith(new RxSubscriber<List<StallRequireBean>>(mView){
                    @Override
                    public void onNext(List<StallRequireBean> data) {
                        mView.onGetStallRequireSuccess(data);
                    }
                })
        );
    }
}
